package com.kcsj.demo.Controller;

import com.kcsj.demo.Mapper.ProductMapper;
import com.kcsj.demo.Module.Product;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Map;

@Controller
public class ProductController {
    @Autowired
    ProductMapper productMapper;
    @GetMapping("product")
    public String productController(Map<String,Object> map){
        map.put("list",productMapper.list());
        return "product";
    }
    @PostMapping("proIns")
    public String proIns(@RequestParam(name = "pro_name") String name,
                         @RequestParam(name = "pro_price") String price,
                         @RequestParam(name = "pro_supplier")String supplier){
        Product product = new Product();
        product.setProductName(name);
        product.setProductPrice(price);
        product.setProductSupplier(supplier);
        productMapper.insert(product);
        return "jump";
    }
    @PostMapping("proDel")
    public String proDel(@RequestParam(name = "proDelete") String proDelete){
        productMapper.delete(proDelete);
        return "jump";
    }
}
